package com.example.library.studentfragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.cardview.widget.CardView;
import androidx.fragment.app.Fragment;

import com.example.library.GroupRoomsActivity;
import com.example.library.HallSeatsActivity;
import com.example.library.R;
import com.example.library.SingleRoomsActivity;

public class StudentSeatFragment extends Fragment {

    private CardView hallAreaCard;
    private CardView singleRoomCard;
    private CardView groupRoomCard;
    private TextView viewAllHallSeats;
    private TextView viewAllSingleRooms;
    private TextView viewAllGroupRooms;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.student_seat, container, false);
        initViews(view);
        setupClickListeners();
        return view;
    }

    private void initViews(View view) {
        hallAreaCard = view.findViewById(R.id.hallAreaCard);
        singleRoomCard = view.findViewById(R.id.singleRoomCard);
        groupRoomCard = view.findViewById(R.id.groupRoomCard);
        viewAllHallSeats = view.findViewById(R.id.viewAllHallSeats);
        viewAllSingleRooms = view.findViewById(R.id.viewAllSingleRooms);
        viewAllGroupRooms = view.findViewById(R.id.viewAllGroupRooms);
    }

    private void setupClickListeners() {
        View.OnClickListener hallClickListener = v -> startActivity(new Intent(getActivity(), HallSeatsActivity.class));
        View.OnClickListener singleRoomClickListener = v -> startActivity(new Intent(getActivity(), SingleRoomsActivity.class));
        View.OnClickListener groupRoomClickListener = v -> startActivity(new Intent(getActivity(), GroupRoomsActivity.class));

        // 设置卡片点击事件
        hallAreaCard.setOnClickListener(hallClickListener);
        singleRoomCard.setOnClickListener(singleRoomClickListener);
        groupRoomCard.setOnClickListener(groupRoomClickListener);

        // 设置"查看全部"按钮点击事件
        viewAllHallSeats.setOnClickListener(hallClickListener);
        viewAllSingleRooms.setOnClickListener(singleRoomClickListener);
        viewAllGroupRooms.setOnClickListener(groupRoomClickListener);
    }
} 